unit Room;

interface

uses
  Database,
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Menus, ExtCtrls, Gauges, StdCtrls, MPlayer, Buttons, jpeg;

type
  TFormRoomMonitor = class(TForm)
    Canvas: TImage;
    MainMenu: TMainMenu;
    MenuMain2: TMenuItem;
    MenuPanic: TMenuItem;
    MenuExit: TMenuItem;
    MenuEscape: TMenuItem;
    MenuHelp: TMenuItem;
    MenuCtrlTab: TMenuItem;
    MenuCtrlTab2: TMenuItem;
    MenuAutotyper: TMenuItem;
    MenuChat: TMenuItem;
    MenuTell: TMenuItem;
    MenuStatus: TMenuItem;
    MenuMessage: TMenuItem;
    MenuFToolbar: TMenuItem;
    MenuFiltered: TMenuItem;
    MenuVariables: TMenuItem;
    MenuMap: TMenuItem;
    Canvas1: TMenuItem;
    PopupRoom: TPopupMenu;
    MenuStayOnTop: TMenuItem;
    N: TImage;
    S: TImage;
    E: TImage;
    W: TImage;
    NE: TImage;
    NW: TImage;
    SW: TImage;
    SE: TImage;
    D: TImage;
    U: TImage;
    Enter: TImage;
    Exit: TImage;
    PanelShort: TPanel;
    NS1: TPanel;
    NS2: TPanel;
    NS3: TPanel;
    NS4: TPanel;
    procedure MenuExitClick(Sender: TObject);
    procedure MenuEscapeClick(Sender: TObject);
    procedure MenuHelpClick(Sender: TObject);
    procedure MenuCtrlTabClick(Sender: TObject);
    procedure MenuAutotyperClick(Sender: TObject);
    procedure MenuPanicClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure MenuStayOnTopClick(Sender: TObject);
    procedure MenuChatClick(Sender: TObject);
    procedure NClick(Sender: TObject);
  private
    { Private declarations }
    procedure WMGetMinMaxInfo(var MSG: Tmessage); message WM_GETMINMAXINFO;
  public
    { Public declarations }
    procedure ProcessCode(code: string);
  end;

var
  FormRoomMonitor: TFormRoomMonitor;

implementation

uses Main;

{$R *.DFM}

procedure TFormRoomMonitor.WMGetMinMaxInfo(var MSG: Tmessage);
begin
  inherited;
  with PMinMaxInfo(MSG.lparam)^ do begin
    with ptMinTrackSize do begin
      X := 215;
      Y := 179;
    end;
    with ptMaxTrackSize do begin
      X := 215;
      Y := 179;
    end;
  end;
end;

procedure TFormRoomMonitor.MenuExitClick(Sender: TObject);
begin
 close;
end;

procedure TFormRoomMonitor.MenuEscapeClick(Sender: TObject);
begin
  FormMain.show;
end;

procedure TFormRoomMonitor.MenuHelpClick(Sender: TObject);
begin
  Datawell.Help('room');
end;

procedure TFormRoomMonitor.MenuCtrlTabClick(Sender: TObject);
begin
  if TMenuItem(sender).tag = 0 then FormMain.NextScreen(12)
  else FormMain.PriorScreen(12);
end;

procedure TFormRoomMonitor.MenuAutotyperClick(Sender: TObject);
begin
  FormMain.OpenFloater(TComponent(sender).tag);
end;

procedure TFormRoomMonitor.MenuPanicClick(Sender: TObject);
begin
  FormMain.MenuPanic.click;
end;

procedure TFormRoomMonitor.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  FormMain.UnloadScreen(2);
end;

procedure TFormRoomMonitor.ProcessCode(code: string);
var
  exits: TStringList;
begin
  exits:=TStringList.create;
  Datawell.explode(code,' ',exits);
  if exits.indexof(Datawell.Dir('n')) >= 0 then begin
    N.show;
    exits.delete(exits.indexof(Datawell.Dir('n')));
  end
  else N.hide;
  if exits.indexof(Datawell.Dir('e')) >= 0 then begin
    E.show;
    exits.delete(exits.indexof(Datawell.Dir('e')));
  end
  else E.hide;
  if exits.indexof(Datawell.Dir('s')) >= 0 then begin
    S.show;
    exits.delete(exits.indexof(Datawell.Dir('s')));
  end
  else S.hide;
  if exits.indexof(Datawell.Dir('w')) >= 0 then begin
    W.show;
    exits.delete(exits.indexof(Datawell.Dir('w')));
  end
  else W.hide;
  if exits.indexof(Datawell.Dir('nw')) >= 0 then begin
    NW.show;
    exits.delete(exits.indexof(Datawell.Dir('nw')));
  end
  else NW.hide;
  if exits.indexof(Datawell.Dir('ne')) >= 0 then begin
    NE.show;
    exits.delete(exits.indexof(Datawell.Dir('ne')));
  end
  else NE.hide;
  if exits.indexof(Datawell.Dir('sw')) >= 0 then begin
    SW.show;
    exits.delete(exits.indexof(Datawell.Dir('sw')));
  end
  else SW.hide;
  if exits.indexof(Datawell.Dir('se')) >= 0 then begin
    SE.show;
    exits.delete(exits.indexof(Datawell.Dir('se')));
  end
  else SE.hide;
  if exits.indexof(Datawell.Dir('u')) >= 0 then begin
    U.show;
    exits.delete(exits.indexof(Datawell.Dir('u')));
  end
  else U.hide;
  if exits.indexof(Datawell.Dir('d')) >= 0 then begin
    D.show;
    exits.delete(exits.indexof(Datawell.Dir('d')));
  end
  else D.hide;
  //do in/enter out/exit
  Enter.hint:='';
  Exit.hint:='';
  if exits.indexof(Datawell.Dir('in')) >= 0 then begin
    Enter.hint:='in';
    exits.delete(exits.indexof(Datawell.Dir('in')));
  end;
  if exits.indexof(Datawell.Dir('enter')) >= 0 then begin
    Enter.hint:='enter';
    exits.delete(exits.indexof(Datawell.Dir('enter')));
  end;
  if exits.indexof(Datawell.Dir('out')) >= 0 then begin
    Exit.hint:='out';
    exits.delete(exits.indexof(Datawell.Dir('out')));
  end;
  if exits.indexof(Datawell.Dir('exit')) >= 0 then begin
    Exit.hint:='exit';
    exits.delete(exits.indexof(Datawell.Dir('exit')));
  end;
  if exits.indexof(Datawell.Dir('leave')) >= 0 then begin
    Exit.hint:='leave';
    exits.delete(exits.indexof(Datawell.Dir('leave')));
  end;
  Enter.visible:=Enter.hint <> '';
  Exit.visible:=Exit.hint <> '';
  //do the first 4 leftover dirs
  NS1.hint:='';
  NS2.hint:='';
  NS3.hint:='';
  NS4.hint:='';
  if Exits.count > 0 then begin
    NS1.hint:=Exits[0];
    Exits.delete(0);
  end;
  if Exits.count > 0 then begin
    NS2.hint:=Exits[0];
    Exits.delete(0);
  end;
  if Exits.count > 0 then begin
    NS3.hint:=Exits[0];
    Exits.delete(0);
  end;
  if Exits.count > 0 then begin
    NS4.hint:=Exits[0];
    Exits.delete(0);
  end;
  NS1.caption:=NS1.hint;
  NS2.caption:=NS2.hint;
  NS3.caption:=NS3.hint;
  NS4.caption:=NS4.hint;
  NS1.visible:=NS1.hint <> '';
  NS2.visible:=NS2.hint <> '';
  NS3.visible:=NS3.hint <> '';
  NS4.visible:=NS3.hint <> '';
  exits.free;
end;

procedure TFormRoomMonitor.MenuStayOnTopClick(Sender: TObject);
begin
  TMenuItem(sender).checked:=not TMenuItem(sender).checked;
  if MenuStayOnTop.checked = true then formstyle:=fsstayontop
  else formstyle:=fsnormal;
end;

procedure TFormRoomMonitor.MenuChatClick(Sender: TObject);
begin
  FormMain.OpenFloater(TComponent(sender).tag);
end;

procedure TFormRoomMonitor.NClick(Sender: TObject);
begin
  FormMain.SendData(Datawell.Dir(TControl(sender).hint),1);
  FormMain.show;
end;

end.
